package com.qf.freemarkertest.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/test")
public class TestController {

    /**
     * model向页面携带数据的模型载体，类似于我们javaweb中学的Request对象，默认就是请求域的数据
     * @param model
     * @return  返回值是表示视图
     */
    @GetMapping
    public String test(Model model){
        model.addAttribute("data","测试数据。。。。");

        model.addAttribute("age",20);

        String[] hobbies = {"ppb","fb","bb"};

        model.addAttribute("hobbies",hobbies);

        return "test";
    }
}
